﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using Kooboo.IoC;
using Kooboo.Commerce;

namespace Kooboo.Web.Areas.Commerce.Controllers
{
    [Authorize(Roles = "Administrator")]
    public class ManagementController : ControllerBase
    {
        IAdministrator _Actor;
        protected IAdministrator Actor
        {
            get
            {
                if (this._Actor == null)
                {

                    if (this.User != null && this.User.Identity.IsAuthenticated)
                    {
                        this._Actor = ContextContainer.Current.Resolve<IAdministrator>();
                        this._Actor.UserName = this.User.Identity.Name;
                    }
                    else
                    {
                        throw new UnauthorizedAccessException();
                    }
                }

                return this._Actor;
            }
        }

    }
}
